/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tools;

import com.jme3.math.Vector3f;
import com.jme3.scene.VertexBuffer.Type;
import com.jme3.scene.shape.Box;
import java.nio.FloatBuffer;

public class MultiFaceBox extends Box {

  public MultiFaceBox() {
    super();
    remap();
  }

  public MultiFaceBox(final Vector3f center, final float xExtent, final float yExtent, final float zExtent) {
    super(center, xExtent, yExtent, zExtent);
    remap();
  }

  public MultiFaceBox(final Vector3f min, final Vector3f max) {
    super(min, max);
    remap();
  }

  private void remap() {
    final FloatBuffer fb = getFloatBuffer(Type.TexCoord);
    fb.rewind();
    for (int i = 0; i < 6; i++) {
      final float top = i / 8f;
      final float bottom = (i + 1) / 8f;
      final float[] tex = new float[] { 1, bottom, 0, bottom, 0, top, 1, top };
      fb.put(tex);
    }
  }
}

